package windows.propertyWindow
{
import windows.*;
	import flash.display.Sprite;
	import com.bit101.components.RadioButton;
	import flash.events.Event;
	import com.bit101.components.Window;
	import com.bit101.components.Label;
	import com.bit101.components.InputText;
	import com.bit101.components.CheckBox;
	import flash.events.MouseEvent;
	import baseitems.Base;
	/**
	 * ...
	 * @author artem.kolesnikov 
	 */
	public class PropertyLabelView extends Sprite 
	{
		private var yPosition:int = 150;
		
		private var alignView3:AlignView;
		private var myLabel1:Label;
		private var sizeField:InputText;
		
		public function PropertyLabelView() 
		{
			alignView3 = new AlignView("text align");
			alignView3.x = 10;
			alignView3.y = yPosition;
			alignView3.groupName = "text_align";
			alignView3.addEventListener(MouseEvent.CLICK, onPropertyChanged);
			addChild(alignView3);
			yPosition += 5;
			myLabel1 = new Label(this, 65, yPosition, "size");
			yPosition += 15;
			sizeField = new InputText(this, 65, yPosition, "32", onTextSizeChange);
			sizeField.width = 30;
		}
		
		private function refresh():void {
			var obj:Base = Controller.instance.selectedObject;

			alignView3.setAlign(obj.labelAlign);
			sizeField.text = obj.textFieldSize.toString();
		}
		
		private function onTextSizeChange(event:Event):void {
			if (Controller.instance.haveSelected) {
				Controller.instance.selectedObject.textFieldSize = int( sizeField.text);
			}
		}
		
		private function onPropertyChanged(event:MouseEvent):void {
			if (Controller.instance.haveSelected) {
				Controller.instance.selectedObject.labelAlign = alignView3.getAlign();
			}
		}
		
		override public function set visible(value:Boolean) :void {
			super.visible = value;
			if (value) {
				refresh();
			}
		}
		
	}

}